package com.healthmgmt.app.controller;

import com.healthmgmt.app.domain.Baby;
import com.healthmgmt.app.service.IBabyService;
import com.healthmgmt.common.core.controller.BaseController;
import com.healthmgmt.common.core.domain.AjaxResult;
import com.healthmgmt.common.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 我的宝贝Controller
 *
 * @author ruoyi
 * @date 2025-06-29
 */
@RestController
@RequestMapping("/app/baby")
public class AppBabyController extends BaseController {
    @Resource
    private IBabyService babyService;

    /**
     * 查询我的宝贝列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Baby baby)
    {
        startPage();
        List<Baby> list = babyService.selectBabyList(baby);
        return getDataTable(list);
    }

    /**
     * 获取我的宝贝详细信息
     */
    @GetMapping(value = "/{babyId}")
    public AjaxResult getInfo(@PathVariable("babyId") Long babyId)
    {
        return success(babyService.selectBabyByBabyId(babyId));
    }

    /**
     * 新增我的宝贝
     */
    @PostMapping
    public AjaxResult add(@RequestBody Baby baby)
    {
        return toAjax(babyService.insertBaby(baby));
    }

    /**
     * 修改我的宝贝
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Baby baby)
    {
        return toAjax(babyService.updateBaby(baby));
    }

    /**
     * 删除我的宝贝
     */
    @DeleteMapping("/{babyIds}")
    public AjaxResult remove(@PathVariable Long[] babyIds)
    {
        return toAjax(babyService.deleteBabyByBabyIds(babyIds));
    }
}
